package com.study.security.core.validate.code.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author LiYongKui
 * @version 1.0
 * @date 2021/4/1 10:30
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ValidateCode implements Serializable {
    private String code;

    private LocalDateTime expireTime;

    public ValidateCode(String code, int expireTime) {
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireTime);
    }

    public Boolean isExpried(){
        return LocalDateTime.now().isAfter(this.expireTime);
    }
}
